package com.hua.api.modules.job.rest;

import com.hua.api.core.constants.Status;
import com.hua.api.core.framework.annotation.AnonymousAccess;
import com.hua.api.core.framework.annotation.TokenCheck;
import com.hua.api.core.framework.util.Result;
import com.hua.api.modules.job.service.JobInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/job")
public class JobInfoController {


    public final JobInfoService jobInfoService;

    /**
     * 已完成的订单，生成结算信息
     * */
    // @AnonymousAccess
    @RequestMapping("/orderBill/create")
    @TokenCheck(userAgent = "orderBillCreate",source = { Status.admin })
    public Result orderBillJob(){
        log.info("JobInfoController.orderBillJob()");
        jobInfoService.orderBillJob();
        return Result.success();
    }

    /**
     * order_info 完成状态同步。
     * */
    // @AnonymousAccess
    @RequestMapping("/orderInfo/sync")
    @TokenCheck(userAgent = "orderInfoStatusSync",source = { Status.admin })
    public Result orderInfoStatusSync(){
        jobInfoService.orderInfoStatusSync();
        return Result.success();
    }

    /**
     * 竞价单状态同步
     * */
    @AnonymousAccess
    @RequestMapping("/orderBid/sync")
    // @TokenCheck(userAgent = "orderInfoStatusSync",source = { Status.admin })
    public Result orderBidStatusSync(){
        jobInfoService.orderBidStatusSync();
        return Result.success();
    }

    /**
     * 订单的配送距离计算
     * */
    @AnonymousAccess
    @RequestMapping("/orderInfo/fixed")
    @TokenCheck(userAgent = "orderInfoFixed",source = { Status.admin })
    public Result orderInfoFixed(){
        jobInfoService.orderInfoFixed();
        return Result.success();
    }

    /**
     * 店铺信息的坐标增加百度坐标系。
     * */
    @AnonymousAccess
    @RequestMapping("/shopInfo/fixed")
    @TokenCheck(userAgent = "shopInfoFixed",source = { Status.admin })
    public Result shopInfoFixed( ){
        jobInfoService.shopInfoFixed();
        return Result.success();
    }

    /**
     * 短信发布。
     * */
    @AnonymousAccess
    @RequestMapping("/sms/sender")
    // @TokenCheck(userAgent = "smsSender",source = { Status.admin })
    public Result smsSender(){
        jobInfoService.smsSenderJob();
        return Result.success();
    }



}
